﻿Imports System
Imports System.Collections.Generic
Imports System.Collections.Specialized
Imports System.IO
Imports System.Linq
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Controls.Primitives
Imports System.Windows.Data
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Navigation

Partial Public Class UserPage
    Inherits Page

    Private ReadOnly _viewModel As UserPageViewModel

    Public Sub New()
        Me.InitializeComponent()
        _viewModel = New UserPageViewModel()
        Me.DataContext = _viewModel
    End Sub

    'Executes when the user navigates to this page.
    Protected Overrides Sub OnNavigatedTo(ByVal e As NavigationEventArgs)
        '如果用户未登录，则跳转到登录页面
        If Application.Current.Resources("UserId") Is Nothing Then
            NavigationService.Navigate(NavigationData.LOGIN_PAGE_URI)
        End If
        '读取URL参数
        Dim queryParams As Dictionary(Of String, String) = Me.NavigationContext.QueryString
        Dim userId As String = queryParams.Item("id")
        If Not String.IsNullOrEmpty(userId) Then
            Call _viewModel.SetUserId(userId)
        End If
    End Sub

End Class
